package com.lmj.demo.pojo;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: lmj
 * @data: 2020/8/10 11:49
 * @email: limajun97@163.com
 * @description:
 */
public class QzUser extends UserExtendDemo {
    public QzUser() {
    }

    public QzUser(String name, Integer money) {
        super(name, money);
    }

    /**
     * 功能描述: <br>
     * 〈发红包的方法〉
     *
     * @param money
     * @param count
     * @return: java.util.ArrayList<java.lang.Integer>
     * @author: limajun97@163.com
     * @date: 2020/8/10 11:51 上午
     * @throws:
     */
    public List<Integer> sendMoney(Integer money, Integer count) {
        List<Integer> moneyList = new ArrayList<>();
        if (money > this.getMoney()) {
            System.out.println("余额额不足，请充值");
            return moneyList;
        }
        Integer avgMoney = money / count;
        for (Integer i = 0; i < count - 1; i++) {
            moneyList.add(avgMoney);
        }
        super.setMoney(super.getMoney() - money);
        moneyList.add(avgMoney + (money % count));
        return moneyList;
    }
}
